#include <reg52.h>

sbit LSA = P2 ^ 2;
sbit LSB = P2 ^ 3;
sbit LSC = P2^4;

unsigned char LEDChar[] = {
	0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
	0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71
};

int main() {
    LSC = 1;LSB = 1;LSA = 1;
    while (1) {
        P1 = 0xf7;
        if (P1 != 0xf7) {
            switch (P1)
            {
            case 0x77:
                P0 = LEDChar[1];
                break;
           	case 0xb7:
                P0 = LEDChar[5];
                break;
			case 0xd7:
                P0 = LEDChar[9];
                break;
			case 0xe7:
                P0 = LEDChar[13];
                break;
            default:
                break;
            }
        }
		P1 = 0xfb;
        if (P1 != 0xfb) {
            switch (P1)
            {
            case 0x7b:
                P0 = LEDChar[2];
                break;
           	case 0xbb:
                P0 = LEDChar[6];
                break;
			case 0xdb:
                P0 = LEDChar[10];
                break;
			case 0xeb:
                P0 = LEDChar[14];
                break;
            default:
                break;
            }
        }
		P1 = 0xfd;
        if (P1 != 0xfd) {
            switch (P1)
            {
            case 0x7d:
                P0 = LEDChar[3];
                break;
           	case 0xbd:
                P0 = LEDChar[7];
                break;
			case 0xdd:
                P0 = LEDChar[11];
                break;
			case 0xed:
                P0 = LEDChar[15];
                break;
            default:
                break;
            }
        }
		P1 = 0xfe;
        if (P1 != 0xfe) {
            switch (P1)
            {
            case 0x7e:
                P0 = LEDChar[4];
                break;
           	case 0xbe:
                P0 = LEDChar[8];
                break;
			case 0xde:
                P0 = LEDChar[12];
                break;
			case 0xee:
                P0 = LEDChar[16];
                break;
            default:
                break;
            }
        }
    }
}